/****************************************************************************
**
**	File Name   : ObjCloneDlg.h
**
**	Project     : DatChecker
**
**	Last Updated: $Header: /DatChecker.root/DatChecker/ObjCloneDlg.h 1     8/14/03 9:25a Neusel $
**
**	Description : 
**
**		CObjClone class interface and implementation.
**
****************************************************************************/
#ifndef	H_OBJCLONEDLG
	#define H_OBJCLONEDLG	__TIMESTAMP__

#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#	pragma once
#endif

class CObjClone :	public CDialogImpl<CObjClone>
	{
public:
	enum { IDD = IDD_OBJRENAME };
protected:
	CFont				m_font;
	CString				m_strName;
	ObjInfo const &		m_objInfo;

	void				setText(int id, LPCTSTR pstr)
							{
							CWindow wnd = GetDlgItem(id);
							
							if (wnd.IsWindow())
								{
								wnd.SetFont(m_font);
								wnd.SetWindowText(pstr);
								}
							}
							
public:
	LPCTSTR				GetName(void) const
							{ return m_objInfo.szName; }
						CObjClone(ObjInfo const & objInfo) : m_objInfo(objInfo)
							{ /* Stub CTOR */ }
/*
**	ATL/WTL VooDoo Code	
*/
protected:
	LRESULT				onChange(WORD, WORD wID, HWND, BOOL & bHandled)
		{
		CEdit	wndEdit = GetDlgItem(IDC_OBJ_NEW_NAME);
		
		if (wndEdit.IsWindow())
			{
			TCHAR	szText[MAX_PATH];
			CButton	wndOK = GetDlgItem(IDOK);
			
			wndEdit.GetWindowText(szText, MAX_PATH);
			m_strName = szText;
			m_strName.TrimRight();

			if (wndOK.IsWindow())
				wndOK.EnableWindow(IsValidName(m_strName) ? TRUE : FALSE);
			}
		else
			m_strName.Empty();
				
		return TRUE;	// return value is ignored
		}		

	LRESULT				onCommand(WORD, WORD wID, HWND, BOOL & bMsgHandled)
		{
		if (wID == IDOK)
			{
			CButton	wndCustom = GetDlgItem(IDC_MAKE_CUSTOM);
			bool	bCustom = (wndCustom.IsWindow() && wndCustom.GetCheck() == BST_CHECKED);
			
			if (CloneObject(m_objInfo, m_strName, bCustom))
				EndDialog(IDOK);
			}
		else if (wID == IDCANCEL)
			EndDialog(wID);
			
		return 0;
		}

	LRESULT				onInitDialog(HWND, LPARAM)
		{
		LOGFONT		lf;
		CDC			dc;

		CenterWindow();
		
 		dc.CreateCompatibleDC();
		::ZeroMemory(&lf, sizeof(LOGFONT));
		lf.lfPitchAndFamily = FF_MODERN;
		lf.lfHeight = -::MulDiv(14, dc.GetDeviceCaps(LOGPIXELSY), 72);
		lf.lfWeight	= FW_BOLD;
		m_font.CreateFontIndirect(&lf);

		setText(IDC_OBJ_OLD_NAME, m_objInfo.szName);
		setText(IDC_OBJ_NEW_NAME, m_objInfo.szName);
		
		return TRUE;
		}

public:
	BEGIN_MSG_MAP_EX(CObjClone)
		MSG_WM_INITDIALOG(onInitDialog)

		COMMAND_ID_HANDLER(IDOK, onCommand)
		COMMAND_ID_HANDLER(IDCANCEL, onCommand)

		COMMAND_HANDLER(IDC_OBJ_NEW_NAME, EN_CHANGE, onChange)

//	    NOTIFY_CODE_HANDLER(EN_UPDATE, onUpdate)
//		REFLECT_NOTIFICATIONS()     
	END_MSG_MAP()
	};
#endif	// H_OBJCLONEDLG
/****************************************************************************
**
**	$History: ObjCloneDlg.h $
 * 
 * *****************  Version 1  *****************
 * User: Neusel       Date: 8/14/03    Time: 9:25a
 * Created in $/DatChecker.root/DatChecker
**
**	-------------------------------------------------------------------------
**
**	End of ObjCloneDlg.h
**
****************************************************************************/
